home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wlib11_4.zip / HEADERS.EXE / VIDSYS.H < prev    next >
C/C++ Source or Header  |  1991-03-23  |  11KB  |  268 lines

  1. /*** VIDSYS.H ***/
  2.  
  3. /* Written By P.A. McKenzie
  4.  * The C Window Library
  5.  * Copyright (C) 1990   All Rights Reserved
  6. */
  7.  /**********************************************
  8.   * Define video and other miscellaneous flags *
  9.   *********************************************/
  10.  
  11. #ifndef VSTRUCT_DEF
  12. #include "proto.h"
  13.  
  14.  #if defined (POWERC)
  15.    #define  crt_status_port  crtport
  16.    #define  pagesize_        pagesiz_
  17.    #define  caldelay_        caldely_
  18. #endif
  19.  
  20. #ifndef offsetof
  21. #define offsetof(type,memb) \
  22.            (unsigned)&((( type *)0x10)->memb)-(unsigned)(( type *)0x10)
  23. #endif
  24.  
  25.  /*************************
  26.  * Define Screen segments *
  27.  *************************/
  28.  
  29. #define MONO  0xB000
  30. #define COLOR 0xB800
  31. #define MAXBUFSIZE    1024
  32. #define MAXSCROLLWIDTH 140
  33.  
  34.  /********************************
  35.   * Define video block structure *
  36.   *******************************/
  37.  
  38. typedef struct
  39. {
  40.   int upx;            /* upper left column where
  41.                          video block is defined */
  42.   int upy;            /* upper row */
  43.   int lowx;           /* lower right column */
  44.   int lowy;           /* lower row */
  45.   int pagenum;        /* page number where block
  46.                          is opened */
  47.   char *scrnsave;     /* pointer to video block
  48.                          structure */
  49. } *VBLOCKPTR, VBLOCK;
  50.  
  51. typedef struct
  52. {
  53.   unsigned  scrnwrt_flag:1;        /* either BIOS or DMA          */
  54.  
  55.   unsigned  cga_flag:1;            /* cga flag                    */
  56.   unsigned  mda_flag:1;            /* mono adapter flag           */
  57.   unsigned  hgc_flag:1;            /* Hercules flag               */
  58.  
  59.   unsigned  vga_in_flag:1;         /* vga installed flag          */
  60.   unsigned  vga_active_flag:1;     /* vga is active flag          */
  61.   unsigned  vga_color_monitor:1;   /* vga color monitor attached  */
  62.   unsigned  vga_color_flag:1;      /* vga color mode on           */
  63.  
  64.   unsigned  mcga_color_flag:1;     /* MCGA color on               */
  65.   unsigned  mcga_in_flag:1;        /* MCGA installed flag         */
  66.  
  67.   unsigned  ega_in_flag:1;         /* ega installed flag          */
  68.   unsigned  ega_active_flag:1;     /* ega active flag             */
  69.   unsigned  ega_color_monitor:1;   /* ega color monitor attached  */
  70.   unsigned  ega_color_flag:1;      /* ega is in color mode flag   */
  71. }  SYS_FLAGS;
  72.  
  73.  
  74. typedef struct
  75. {
  76.   unsigned int video_mode;         /* current video mode */
  77.   unsigned int cursor_startline;   /* starting scan line of the cursor */
  78.   unsigned int cursor_endline;     /* ending scan line of the cursor */
  79.   unsigned int cursor_row;         /* row of cursor */
  80.   unsigned int cursor_col;         /* column of cursor */
  81.   unsigned int video_page;         /* video page */
  82.   unsigned int video_pagesize;     /* video page size in bytes */
  83.   unsigned int video_rows;         /* number of displayable rows */
  84.   unsigned int video_cols;         /* number of displayable columns */
  85.   unsigned int char_height;        /* height of characters in scan lines */
  86.   unsigned int crt_port_address;   /* address of crt status port */
  87.   unsigned int crt_mode_setting;   /* mode setting of crt */
  88.   unsigned int crt_color_setting;  /* color setting of crt */
  89. } VIDEO_CONFIG;
  90.  
  91. #if defined (GLOBAL_DEF)
  92. #define EXTERN
  93. #else
  94. #define EXTERN extern
  95. #endif
  96.  
  97. EXTERN VIDEO_CONFIG   initial_video_startup;
  98. EXTERN int            is_vga_color;
  99. EXTERN int            default_screen_attr;         /* default screen attribute */
  100. EXTERN int            default_screen_tab_length;
  101. EXTERN unsigned       scrnseg_;
  102. EXTERN unsigned char  chksnow_;
  103. EXTERN SYS_FLAGS      video_system_flags;
  104. EXTERN unsigned       crt_status_port;
  105. EXTERN int            num_screen_rows;             /* current # of rows displayed */
  106. EXTERN int            num_screen_cols;             /* current # of columns displayed */
  107. EXTERN int            max_video_pages;
  108. EXTERN int            active_video_page;         /* current active display page */
  109. EXTERN int            visible_video_page;        /* current visible display page */
  110. EXTERN unsigned int   pagesize_;   /* size of video page in bytes */
  111. EXTERN int            current_video_mode;             /* current video mode */
  112. EXTERN unsigned char  window_char_buffer[MAXBUFSIZE]; /* global write buffer */
  113. EXTERN unsigned char  virtual_char_buffer[MAXBUFSIZE];
  114. EXTERN unsigned char  scroll_char_buffer[MAXSCROLLWIDTH];
  115. EXTERN unsigned       caldelay_;
  116.  
  117.  
  118.  /*******************
  119.  * Define box types *
  120.  ********************/
  121.  
  122.  
  123. #define DOUBLEBOX      "╔═╗║║╚═╝"
  124. #define SINGLEBOX      "┌─┐││└─┘"
  125. #define MIXEDBOX1      "╒═╕││╘═╛"
  126. #define MIXEDBOX2      "╓─╖║║╙─╜"
  127. #define HATCHBOX1      "░░░░░░░░"
  128. #define HATCHBOX2      "▒▒▒▒▒▒▒▒"
  129. #define HATCHBOX3      "▓▓▓▓▓▓▓▓"
  130. #define SOLIDBOX1      "█▀████▄█"
  131. #define SOLIDBOX2      "████████"
  132. #define BLANKBOX       "        "
  133. #define DOTTEDLINE     "---||---"
  134.  
  135.  
  136. #ifndef NUMBOXCHARS
  137. #define NUMBOXCHARS  8
  138. #endif
  139.  
  140. /* Macro Definitions */
  141.  
  142. #define SCREEN_WRITE_METHOD       video_system_flags.scrnwrt_flag
  143. #define CGA_ACTIVE                video_system_flags.cga_flag
  144.  
  145. #define VGA_INSTALLED             video_system_flags.vga_in_flag
  146. #define VGA_ACTIVE                video_system_flags.vga_active_flag
  147. #define VGA_COLOR_ON              video_system_flags.vga_color_flag
  148.  
  149. #define MCGA_COLOR_ON             video_system_flags.mcga_color_flag
  150. #define MCGA_INSTALLED            video_system_flags.mcga_in_flag
  151.  
  152. #define EGA_INSTALLED             video_system_flags.ega_in_flag
  153. #define EGA_ACTIVE                video_system_flags.ega_active_flag
  154. #define EGA_COLOR_ON              video_system_flags.ega_color_flag
  155.  
  156. #define VGA_MONO_ON               (VGA_ACTIVE && !VGA_COLOR_ON)
  157. #define EGA_MONO_ON               (EGA_ACTIVE && !EGA_COLOR_ON)
  158. #define HERCULES_ACTIVE           video_system_flags.hgc_flag
  159. #define MDA_ACTIVE                video_system_flags.mda_flag
  160. #define VGA_COLOR_ATTACHED        video_system_flags.vga_color_monitor
  161. #define EGA_COLOR_ATTACHED        video_system_flags.ega_color_monitor
  162.  
  163. #define MONO_MODE_ON              ((!EGA_COLOR_ON && !VGA_COLOR_ON && \
  164.                                     !MCGA_COLOR_ON && !CGA_ACTIVE) || \
  165.                                    (MDA_ACTIVE || HERCULES_ACTIVE))
  166.  
  167. #define COLOR_MODE_ON             (!MONO_MODE_ON)
  168. #define VGA_MODE_ON               (VGA_ACTIVE)
  169. #define EGA_MODE_ON               (EGA_ACTIVE)
  170. #define CGA_MODE_ON               (CGA_ACTIVE)
  171. #define MCGA_MONO_ON              (MCGA_INSTALLED && VGA_ACTIVE && \
  172.                                    !MCGA_COLOR_ON)
  173. #define MCGA_MODE_ON              (MCGA_INSTALLED && VGA_ACTIVE)
  174. #define VGA_MONO_ATTACHED         (VGA_ACTIVE && !VGA_COLOR_ATTACHED)
  175.  
  176. #define CHECK_SNOW                chksnow_
  177. #define SCREEN_SEGMENT            scrnseg_
  178. #define VIDEO_PAGESIZE            pagesize_
  179.  
  180. /*  Video Macros */
  181.  
  182. #define LINEMODE43       (get_video_info(4) == 43)
  183. #define LINEMODE50       (get_video_info(4) == 50)
  184. #define LINEMODE25       (get_video_info(4) == 25)
  185.  
  186. #define CREATE_VIDEO_ATTRIBUTE(x,y) (((int)(x)<<4) + (y)) /* creates a video attribute */
  187.  
  188. #define GET_BGROUND_COLOR(c)        ((int)(c)>>4)
  189. #define GET_FGROUND_COLOR(c)        ((int)(c) & 0x000F)
  190.  
  191. #define SCREEN_OFFSET(r,c,a)  \
  192.                           (((((r)-1)*num_screen_cols + (c)-1) + (a)*pagesize_)<<1)
  193. #define GET_SEGMENT(x)  \
  194.                   ((unsigned) ((long)(char far *)(x) >> 16))
  195. #define GET_OFFSET(x)   \
  196.                    ((unsigned) ((long)(char far *)(x) & 0x0000FFFF))
  197. #define SCREEN_OFFSET_ATTR(r,c,a)        (SCREEN_OFFSET((r),(c),(a))+1)
  198.  
  199. #define MAKE_FAR_POINTER(a,b)  ((char far *)(((unsigned long)(a) << 16)+(b)))
  200.  
  201.  
  202. #define GetVideoAttribute(row,col,page)   get_chat((row),(col),(page),1)
  203. #define GetVideoMode()                    get_video_info(1)
  204. #define MoveCursor(row,col,page)          goto_xy((row),(col),(page))
  205. #define ReportCharacter(row,col,page)     get_chat((row),(col),(page),0)
  206.  
  207.  
  208.  
  209. #if __cplusplus
  210.   extern "C" {
  211. #endif
  212.  
  213.  
  214.  
  215. /* Fast Output/Non-window related Video Functions */
  216. int           CheckVideoPage P((int page));
  217. void          ClearRegion P((int urow, int ucol, int lrow, int lcol, int attr));
  218. void          ClearScreen P((int attr));
  219. void          GetCursorPosition P((unsigned *row, unsigned *col, int page));
  220. void          GetVideoBiosInfo P((VIDEO_CONFIG *video_struct));
  221. void          ScrollScreenUp P((int numlines, int urow, int ucol, int lrow,
  222.                                 int lcol, int attr));
  223. void          ScrollScreenDown P((int numlines, int urow, int ucol, int lrow,
  224.                                 int lcol, int attr));
  225. int           SetActiveVideoPage P((int page));
  226. int           SetVisibleVideoPage P((int page));
  227. void          SetVideoMode P((int modenum));
  228. int           SetVideoRows P((int numrows, int flag));
  229. void          VideoDrawBox P((int urow, int ucol, int lrow, int lcol, char *box));
  230. void          VideoDrawBoxAttr P((int urow, int ucol, int lrow, int lcol,
  231.                                   char *box, int attr));
  232. void          VideoFree P((VBLOCKPTR vid_block));
  233. void          VideoMove P((VBLOCKPTR vid_block, int row, int col));
  234. void          VideoPrintf P((char *format, ...));
  235. void          VideoPrintfAttr P((int attr, char *format, ...));
  236. VBLOCKPTR     VideoSave P((int urow, int ucol, int lrow, int lcol));
  237. void          VideoRestore P((VBLOCKPTR vid_block));
  238. void          VideoWriteString P((char *string, int row, int col));
  239. void          VideoWriteStringAttr P((char *string, int row, int col, int attr));
  240. void          VideoWriteAttributes P((char *string, int row, int col,
  241.                                       int length));
  242. void          VideoWriteCenterString P((char *string, int row));
  243. void          VideoWriteCenterStringAttr P((char *string, int row, int attr));
  244. void          VideoWriteCharAndAttr P((char *string, int row, int col,
  245.                                        int length));
  246. void          VideoWriteStringCC P((char *string, int row, int col));
  247. void          VideoWriteStringCCAttr P((char *string, int row, int col,
  248.                                         int attr));
  249. void          VideoWriteStringRJ P((char *string, int row, int col));
  250. void          VideoWriteStringRJAttr P((char *string, int row, int col,
  251.                                         int attr));
  252. void          VideoReadAttributes P((char *buffer, int row, int col,
  253.                                      int length));
  254. void          VideoReadCharacters P((char *buffer, int row, int col,
  255.                                      int length));
  256. void          VideoReadCharAndAttr P((char *buffer, int row, int col,
  257.                                       int length));
  258.  
  259. int           InitializeScanLines(int,int);
  260. int           LoadCharacterSet(int,int);
  261. void          goto_xy P((int,int,int));
  262. #if __cplusplus
  263.   }
  264. #endif
  265. #define VSTRUCT_DEF
  266.  
  267. #endif
  268.